package TestDemo2;

interface Iusb {

    void open();//打开
    void close();//关闭

}

class Mouse implements Iusb {

    @Override
    public void open() {
        System.out.println("打开鼠标");
    }

    @Override
    public void close() {
        System.out.println("关闭鼠标");
    }
    public void click() {
        System.out.println("点击鼠标");
    }
}
class Keyboard implements Iusb {

    @Override
    public void open() {
        System.out.println("打开键盘");
    }

    @Override
    public void close() {
        System.out.println("关闭键盘");
    }
    public void typing() {
        System.out.println("敲击键盘输入数据");
    }
}
class computer  {

    public static void opencomputer() {
        System.out.println("打开电脑");
    }

    public static void closecomputer() {
        System.out.println("关闭电脑");
    }
    public static void draw(Iusb iusb) {
        opencomputer();
        iusb.open();
         if(iusb instanceof Mouse) {
            ((Mouse) iusb).click();
         } else {
            ((Keyboard) iusb).typing();
        }
        iusb.close();//关闭设备
        closecomputer();//关闭电脑
    }
}
public class Test {
    public static void main(String[] args) {
        computer.draw(new Mouse());
        System.out.println("==========");
        computer.draw(new Keyboard());
    }
}
